<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title><?php echo SYS_NAME ?></title>
        <meta name="keywords" content="<?php echo SYS_NAME ?>">
        <meta name="description" content="">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="icon" href="{$sys_url.static}images/favicon.ico" type="images/x-ico" />
        <link rel="stylesheet" href="{$sys_url.static}layui/css/layui.css" media="all">
        <link rel="stylesheet" href="{$sys_url.static}css/login.css" media="all">
    </head>
    <body>
        <div class="layui-container">
            <div class="layui-row">
                <div class="layui-col-lg12 p1">

                    <span></span><span><b>{$sys_url.name}</b><cite>坚持写下去</cite></span>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-lg12 p2">
                    <div class="layui-col-lg6"><img src="{$sys_url.static}images/loginbg.png" /></div>
                    <div class="layui-col-lg6">

                        <form class="layui-form">
                            <div class="box">
                                <div class="title"><span>用户登录</span><i>User login</i></div>
                                <div class="content">
                                    <div class="layui-form-item t">
                                        <span>
                                            <i class="layui-icon layui-icon-username"></i><cite>|</cite><input type="text" name="account" value="" required lay-verify="required" placeholder="请输入账号" autocomplete="off">
                                        </span>
                                    </div>
                                    <div class="layui-form-item t">
                                        <span>
                                            <i class="layui-icon layui-icon-password"></i><cite>|</cite><input type="password" name="password" value="" required lay-verify="required" placeholder="请输入密码" autocomplete="off">
                                        </span>
                                    </div>
                                    <div class="layui-form-item t">
                                        <span class="codeBox">
                                            <i class="layui-icon layui-icon-vercode"></i><cite>|</cite><input type="text" name="code" value="" required lay-verify="required" placeholder="验证码" autocomplete="off" class="code">
                                        </span><img src="{$sys_url.root}Admin/Tool/createVerifyCode" id="iCodeImage" alt="验证码" title="点击更换" />
                                    </div>
                                    <div class="tips"></div>
                                </div>
                                <div class="btn">
                                    <button class="layui-btn" lay-submit lay-filter="submit">立即登录</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="p3 copyright" style="padding-top: 100px">Copyright 2020 <?php echo SYS_NAME ?> 备案号：XXXXXXXXXXXXXX</div>
        </div>
    </body>
    <script src="{$sys_url.static}layui/layui.js" charset="utf-8"></script>
    <script>
        layui.use('form', function() {
            var form = layui.form;
            var $ = layui.jquery;

            //监听提交
            form.on('submit(submit)', function(data) {
                $.ajax({
                    url: '{$sys_url.root}Admin/Index/login_ajax',
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    beforeSend: function() {
                        //do something
                    },
                    success: function(data) {
                        console.log(data);
                        //do something
                        if (data.code == 1) {
                            location.href =  "{$sys_url.root}Admin/Index/index";
                        } else {
                            $('#iCodeImage').attr('src', '{$sys_url.root}Admin/Tool/createVerifyCode?' + Math.random());
                            $('.tips').text(data.msg);
                        }
                    },
                    error: function(data) {
                        console.log(data);
                        //do something
                        layer.msg('与服务器连接失败', {icon: 2});
                    }
                });
                return false;
            });
            $('#iCodeImage').on('click', function() {
                $(this).attr('src', '{$sys_url.root}Admin/Tool/createVerifyCode?' + Math.random());
            });
        });
    </script>
</html>